package ckw.database;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import core.interfaces.Checkable;

public class VotersList extends Checkable implements Serializable {

	private static final long serialVersionUID = -3492897338302855459L;

	private Long id;
	private String name;
	private String description;
	private Set<Voter> voters = new HashSet<Voter>();
	private Set<Election> elections = new HashSet<Election>();

	public VotersList() {
	}

	public VotersList(String name, String description) {
		super();
		this.name = name;
		this.description = description;
	}

	@SuppressWarnings("unused")
	private void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Set<Voter> getVoters() {
		return voters;
	}

	public void setVoters(Set<Voter> voters) {
		this.voters = voters;
	}

	public void addToVoter(Voter voter) {
		this.getVoters().add(voter);
		voter.getVotersLists().add(this);
	}

	public void removeFromVoter(Voter voter) {
		this.getVoters().remove(voter);
		voter.getVotersLists().remove(this);
	}

	public Set<Election> getElections() {
		return elections;
	}

	public void setElections(Set<Election> elections) {
		this.elections = elections;
	}

	public void removeFromElection(Election election) {
		this.getElections().remove(election);
		election.getVotersLists().remove(this);
	}
}
